package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cheer.entity.StandingBook;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface StandingBookDao extends BaseMapper<StandingBook> {

    default StandingBook getByAccountId(Long accountId) {
        return selectOne(new QueryWrapper<StandingBook>()
                .eq("account_id", accountId)
                .last("limit 1"));
    }

    default void deleteByAccountIds(List<Long> accountIds) {
        delete(new QueryWrapper<StandingBook>()
                .in("account_id", accountIds));
    }
}
